<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>simple publish page</title>
    <style type="text/css">
      body {
        padding-top: 40px;
        font-family: "SF Pro Text","Myriad Set Pro","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif;
      }
      form {
        margin: 10px auto;
        width: 560px;
        background: #E6E6E6;
        border-radius: 8px;
        padding: 20px;
      }
      textarea {
        width: 300px;
        height: 60px;
      }
      input {
        padding: 4px;
      }
      .desc {
        background: #efefef;
        padding: 10px 5px;
      }
    </style>
  </head>
  <body>
  <% if(publishPage === 'true'){ %>

    <form id="uploadApp" onsubmit="return upload(this)" action="./api/defaultPublish" method="post" enctype='multipart/form-data'>
      <h2>Install App</h2>
      <p class="desc">
        this page is only for init honeycomb-console.<br/>
        the <font color="green">password</font> is configed at <font color="red">config.admin.password</font>
        <br/>
        <br/>
        when console inited, make sure close this page by setting up: <font color="red">config.admin.enablePublishPage: false</font>
      </p>
      <div>
         <p>password: <input name="password" type="password" /></p>
      </div>
      <div>
        <p>select app package file(.tgz): </p>
        <input style="padding-left: 20px" type="file" name="pkg" id="pkg">
      </div>
      <div style="margin-top: 20px;">
        <p>publish to machines(each line a ip):</p>
        <span style="padding-left: 20px">
          <textarea id="ips" name="ipList"><%= ipList.join('\n') %></textarea>
        </span>
      </div>
      <div style="margin-top: 20px;">
        <input type="submit" value="publish app" style="width:100px; font-size: 30px;">
      </div>
    </form>
    <script type="text/javascript">
      function upload(form) {
        let file = document.querySelector('#pkg').value;
        if (!file) {
          alert('please select a app package');
          return false;
        }
        return true;
      }
    </script>
  <% } else { %>
    <div class="container-fluid">
      <h2><%= message %></h2>
      <p><%= ipList.join('; ') %></p>
      <pre><%= log %></pre>
    </div>
  <% } %>
  </body>
</html>
